import 'package:baselib/widgets/comm_app_bar.dart';
import 'package:baselib/widgets/nosize_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';
import 'package:module_business/module_comm/viewmodel/home_view_model.dart';
/**
 * home主页界面
 */
class HomePage extends GetWidget<HomeViewModel> {

  @override
  Widget build(BuildContext context) {
    return PageWidget.build(
      builder: (HomeViewModel model){
        return WillPopScope(
          onWillPop: ()=>model?.doubleBackExit(),
          child: PageWidget.PageScaffoldWidget(
            bottomNavigationBar:BottomNavigationBar( //源码中高度BottomNavigationBar 56
              items: <BottomNavigationBarItem>[
                BottomNavigationBarItem(
                    icon: model.getTabIcon(0),
                  label: ''
                ),
                BottomNavigationBarItem(
                    icon: model.getTabIcon(1),
                    label: ''
                ),
                BottomNavigationBarItem(
                    icon: model.getTabIcon(2),
                    label: ''
                ),
                BottomNavigationBarItem(
                    icon: model.getTabIcon(3),
                    label: ''
                ),
              ],
              type: BottomNavigationBarType.fixed,
              currentIndex: model.tabIndex,
              elevation: PxUtil.instance.px_5,
              iconSize: PxUtil.instance.px_30,
              selectedFontSize: PxUtil.instance.px_0,
              unselectedFontSize: PxUtil.instance.px_0,
              backgroundColor: ColorUtil.instance.color_2F3660,
              // backgroundColor: ColorUtil.instance.color_272e54,
              onTap: (index)=>model.onBottomItemTap(index),
            ),
            body:PageView(
              physics: NeverScrollableScrollPhysics(),
              controller: model.pageController,
              onPageChanged: (int pageIndex)=>model.onPageChanged(pageIndex),
              children: model.pages,
            )
            // IndexedStack(
            //   index: model.tabIndex,
            //   children: model.pageList,
            // ),
          ),
        );
      }
    );
  }
}

